#!/bin/bash
#安装必要依赖
#参考地址：https://docs.opencv.org/3.4/d7/d9f/tutorial_linux_install.html
#可切换版本
sudo apt-get install build-essential
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev


git clone https://github.com/opencv/opencv.git
cd opencv
#切换至指定版本
git checkout -b 3.4 origin/3.4
#git checkout -b 2.4 origin/2.4
mkdir release
cd release/
cmake ../ -DCMAKE_BUILD_TYPE=RELEASE -DsCMAKE_INSTALL_PREFIX=/usr/local
make -j8
sudo make install
#安装完成
#添加库环境变量
#sudo echo "/usr/loacal/lib" > /etc/ld.so.conf.d/opencv.conf
#使手动安装库立即生效
sudo ldconfig
